2020-2021 Sunseeker Telemetry and Lighting System
eusci_b_spi.h
Go to the documentation of this file.
1 //*****************************************************************************
2 //
3 // eusci_b_spi.h - Driver for the EUSCI_B_SPI Module.
4 //
5 //*****************************************************************************
6 
7 #ifndef __MSP430WARE_EUSCI_B_SPI_H__
8 #define __MSP430WARE_EUSCI_B_SPI_H__
9 
10 #include "inc/hw_memmap.h"
11 
12 #ifdef __MSP430_HAS_EUSCI_Bx__
13 
14 //*****************************************************************************
15 //
16 // If building with a C++ compiler, make all of the definitions in this header
17 // have a C binding.
18 //
19 //*****************************************************************************
20 #ifdef __cplusplus
21 extern "C"
22 {
23 #endif
24 
25 #include "inc/hw_memmap.h"
26 //*****************************************************************************
27 //
30 //
31 //*****************************************************************************
32 typedef struct EUSCI_B_SPI_initMasterParam {
38  uint8_t selectClockSource;
40  uint32_t clockSourceFrequency;
42  uint32_t desiredSpiClock;
47  uint16_t msbFirst;
52  uint16_t clockPhase;
57  uint16_t clockPolarity;
63  uint16_t spiMode;
64 } EUSCI_B_SPI_initMasterParam;
65 
66 //*****************************************************************************
67 //
69 //
70 //*****************************************************************************
71 typedef struct EUSCI_B_SPI_initSlaveParam {
76  uint16_t msbFirst;
81  uint16_t clockPhase;
86  uint16_t clockPolarity;
92  uint16_t spiMode;
93 } EUSCI_B_SPI_initSlaveParam;
94 
95 //*****************************************************************************
96 //
99 //
100 //*****************************************************************************
101 typedef struct EUSCI_B_SPI_changeMasterClockParam {
103  uint32_t clockSourceFrequency;
105  uint32_t desiredSpiClock;
106 } EUSCI_B_SPI_changeMasterClockParam;
107 
108 
109 //*****************************************************************************
110 //
111 // The following are values that can be passed to the clockPhase parameter for
112 // functions: EUSCI_B_SPI_changeClockPhasePolarity(); the param parameter for
113 // functions: EUSCI_B_SPI_initMaster(), and EUSCI_B_SPI_initSlave().
114 //
115 //*****************************************************************************
116 #define EUSCI_B_SPI_PHASE_DATA_CHANGED_ONFIRST_CAPTURED_ON_NEXT 0x00
117 #define EUSCI_B_SPI_PHASE_DATA_CAPTURED_ONFIRST_CHANGED_ON_NEXT UCCKPH
118 
119 //*****************************************************************************
120 //
121 // The following are values that can be passed to the param parameter for
122 // functions: EUSCI_B_SPI_initMaster(), and EUSCI_B_SPI_initSlave().
123 //
124 //*****************************************************************************
125 #define EUSCI_B_SPI_MSB_FIRST UCMSB
126 #define EUSCI_B_SPI_LSB_FIRST 0x00
127 
128 //*****************************************************************************
129 //
130 // The following are values that can be passed to the param parameter for
131 // functions: EUSCI_B_SPI_initMaster(), and EUSCI_B_SPI_initSlave(); the
132 // clockPolarity parameter for functions:
133 // EUSCI_B_SPI_changeClockPhasePolarity().
134 //
135 //*****************************************************************************
136 #define EUSCI_B_SPI_CLOCKPOLARITY_INACTIVITY_HIGH UCCKPL
137 #define EUSCI_B_SPI_CLOCKPOLARITY_INACTIVITY_LOW 0x00
138 
139 //*****************************************************************************
140 //
141 // The following are values that can be passed to the param parameter for
142 // functions: EUSCI_B_SPI_initMaster().
143 //
144 //*****************************************************************************
145 #define EUSCI_B_SPI_CLOCKSOURCE_ACLK UCSSEL__ACLK
146 #define EUSCI_B_SPI_CLOCKSOURCE_SMCLK UCSSEL__SMCLK
147 
148 //*****************************************************************************
149 //
150 // The following are values that can be passed to the param parameter for
151 // functions: EUSCI_B_SPI_initMaster(), and EUSCI_B_SPI_initSlave().
152 //
153 //*****************************************************************************
154 #define EUSCI_B_SPI_3PIN UCMODE_0
155 #define EUSCI_B_SPI_4PIN_UCxSTE_ACTIVE_HIGH UCMODE_1
156 #define EUSCI_B_SPI_4PIN_UCxSTE_ACTIVE_LOW UCMODE_2
157 
158 //*****************************************************************************
159 //
160 // The following are values that can be passed to the select4PinFunctionality
161 // parameter for functions: EUSCI_B_SPI_select4PinFunctionality().
162 //
163 //*****************************************************************************
164 #define EUSCI_B_SPI_PREVENT_CONFLICTS_WITH_OTHER_MASTERS 0x0000
165 #define EUSCI_B_SPI_ENABLE_SIGNAL_FOR_4WIRE_SLAVE UCSTEM
166 
167 //*****************************************************************************
168 //
169 // The following are values that can be passed to the mask parameter for
170 // functions: EUSCI_B_SPI_enableInterrupt(), EUSCI_B_SPI_disableInterrupt(),
171 // EUSCI_B_SPI_getInterruptStatus(), and EUSCI_B_SPI_clearInterrupt() as well
172 // as returned by the EUSCI_B_SPI_getInterruptStatus() function.
173 //
174 //*****************************************************************************
175 #define EUSCI_B_SPI_TRANSMIT_INTERRUPT UCTXIE
176 #define EUSCI_B_SPI_RECEIVE_INTERRUPT UCRXIE
177 
178 //*****************************************************************************
179 //
180 // The following are values that can be passed toThe following are values that
181 // can be returned by the EUSCI_B_SPI_isBusy() function.
182 //
183 //*****************************************************************************
184 #define EUSCI_B_SPI_BUSY UCBUSY
185 #define EUSCI_B_SPI_NOT_BUSY 0x00
186 
187 //*****************************************************************************
188 //
189 // Prototypes for the APIs.
190 //
191 //*****************************************************************************
192 
193 //*****************************************************************************
194 //
208 //
209 //*****************************************************************************
210 extern void EUSCI_B_SPI_initMaster(uint16_t baseAddress,
211  EUSCI_B_SPI_initMasterParam *param);
212 
213 //*****************************************************************************
214 //
229 //
230 //*****************************************************************************
231 extern void EUSCI_B_SPI_select4PinFunctionality(uint16_t baseAddress,
232  uint16_t select4PinFunctionality);
233 
234 //*****************************************************************************
235 //
245 //
246 //*****************************************************************************
247 extern void EUSCI_B_SPI_changeMasterClock(uint16_t baseAddress,
248  EUSCI_B_SPI_changeMasterClockParam *param);
249 
250 //*****************************************************************************
251 //
265 //
266 //*****************************************************************************
267 extern void EUSCI_B_SPI_initSlave(uint16_t baseAddress,
268  EUSCI_B_SPI_initSlaveParam *param);
269 
270 //*****************************************************************************
271 //
290 //
291 //*****************************************************************************
292 extern void EUSCI_B_SPI_changeClockPhasePolarity(uint16_t baseAddress,
293  uint16_t clockPhase,
294  uint16_t clockPolarity);
295 
296 //*****************************************************************************
297 //
307 //
308 //*****************************************************************************
309 extern void EUSCI_B_SPI_transmitData(uint16_t baseAddress,
310  uint8_t transmitData);
311 
312 //*****************************************************************************
313 //
322 //
323 //*****************************************************************************
324 extern uint8_t EUSCI_B_SPI_receiveData(uint16_t baseAddress);
325 
326 //*****************************************************************************
327 //
343 //
344 //*****************************************************************************
345 extern void EUSCI_B_SPI_enableInterrupt(uint16_t baseAddress,
346  uint16_t mask);
347 
348 //*****************************************************************************
349 //
365 //
366 //*****************************************************************************
367 extern void EUSCI_B_SPI_disableInterrupt(uint16_t baseAddress,
368  uint16_t mask);
369 
370 //*****************************************************************************
371 //
387 //
388 //*****************************************************************************
389 extern uint8_t EUSCI_B_SPI_getInterruptStatus(uint16_t baseAddress,
390  uint8_t mask);
391 
392 //*****************************************************************************
393 //
405 //
406 //*****************************************************************************
407 extern void EUSCI_B_SPI_clearInterrupt(uint16_t baseAddress,
408  uint16_t mask);
409 
410 //*****************************************************************************
411 //
421 //
422 //*****************************************************************************
423 extern void EUSCI_B_SPI_enable(uint16_t baseAddress);
424 
425 //*****************************************************************************
426 //
436 //
437 //*****************************************************************************
438 extern void EUSCI_B_SPI_disable(uint16_t baseAddress);
439 
440 //*****************************************************************************
441 //
450 //
451 //*****************************************************************************
452 extern uint32_t EUSCI_B_SPI_getReceiveBufferAddress(uint16_t baseAddress);
453 
454 //*****************************************************************************
455 //
464 //
465 //*****************************************************************************
466 extern uint32_t EUSCI_B_SPI_getTransmitBufferAddress(uint16_t baseAddress);
467 
468 //*****************************************************************************
469 //
481 //
482 //*****************************************************************************
483 extern uint16_t EUSCI_B_SPI_isBusy(uint16_t baseAddress);
484 
485 //*****************************************************************************
486 //
487 // Mark the end of the C bindings section for C++ compilers.
488 //
489 //*****************************************************************************
490 #ifdef __cplusplus
491 }
492 #endif
493 
494 #endif
495 #endif // __MSP430WARE_EUSCI_B_SPI_H__
uint8_t transmitData
MPU_initThreeSegmentsParam param